import * as React from 'react'
import classNames from 'classnames'

import { AnimProps, AnimState } from './interface'

class Anim extends React.Component<AnimProps, AnimState> {
  static defaultProps = {
    prefixCls: 'layui-anim'
  }
  constructor(props: AnimProps) {
    super(props)
    this.state = {}
  }

  render() {
    const {
      prefixCls, className,
      type, children,
      ...restProps
    } = this.props
    // 多个type 用'|'分割
    let typeCls = ''
    if (type) {
      typeCls = type.split('|').map(x => `${prefixCls}-${x}`).join(' ')
    }
    const classes = classNames(prefixCls, className, typeCls)

    return (
      <div
        className={classes}
        {...restProps}
      >
        {children}
      </div>
    )
  }
}

export default Anim